
package com.insigma.business.qrcode.welfare._bff.impl;

import com.insigma.business.qrcode.common.util.BizCheckUtil;
import com.insigma.business.qrcode.common.util.RpcContextUtil;
import com.insigma.business.qrcode.common.vo.BaseResponse;
import com.insigma.business.qrcode.common.vo.SessionSoldier;
import com.insigma.business.qrcode.soldier.dto.gov.BaseProviderImpl;
import com.insigma.business.qrcode.welfare.dto.MarketingSpotDeliveryDTO;
import com.insigma.business.qrcode.welfare.dto.request.MarketingSpotSearchRequest;
import com.insigma.business.qrcode.welfare._bff.MarketingSpotBFFProvider;
import com.insigma.business.qrcode.welfare._consumer.MarketingSpotConsumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;


@Slf4j
@Service
@Component("marketingSpotBFFProvider")
public class MarketingSpotBFFProviderImpl extends BaseProviderImpl implements MarketingSpotBFFProvider {

    @Autowired
    private MarketingSpotConsumer marketingSpotConsumer;

    @Override
    public BaseResponse<MarketingSpotDeliveryDTO> deliveryMaterial(MarketingSpotSearchRequest request) {

        BizCheckUtil.checkNotNull(request, "请求不能为空");
        BizCheckUtil.checkNotNull(request.getCode(), "code不能为空");

        SessionSoldier sessionSoldier = RpcContextUtil.getSessionSoldier();
        if (sessionSoldier != null) {
            request.setSoldierId(sessionSoldier.getUserId());
        }
        return marketingSpotConsumer.deliveryMaterial(request);
    }
}
